home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Magazine / C_Tutorial / Part-12 / dt0 / screen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-13  |  1.2 KB  |  50 lines

  1. /* Open screen and setup GadTools stuff */
  2. #include "screen.h"
  3.  
  4. #include<stdio.h>
  5.  
  6. #include<clib/intuition_protos.h>
  7.  
  8. #define MY_TITLE "Hello World Painter"
  9.  
  10. /* Global record of our screen */
  11. struct Screen* screen = NULL;
  12.  
  13. int openScreen(UBYTE depth, UWORD width, UWORD height, ULONG displayid)
  14. {
  15.     UWORD pens[] = { ~0 };
  16.     /* Try to open a new screen with requested properties */
  17.     /* (A parameter of zero will be ignored, so the default */
  18.     /* value will be used by the screen) */
  19.     if(screen = OpenScreenTags(NULL,
  20.                                                          depth ?        SA_Depth : TAG_IGNORE,            depth,
  21.                                                          width ?        SA_Width : TAG_IGNORE,            width,
  22.                                                          height ?    SA_Height : TAG_IGNORE,                height,
  23.                                                          displayid ? SA_DisplayID : TAG_IGNORE,    displayid,
  24.                                                          /* Enable 3D look by specifying SA_Pens */
  25.                                                          SA_Pens,    pens,
  26.                                                          SA_Title,    MY_TITLE,
  27. //                                                         SA_Type,   PUBLICSCREEN,
  28. //                                                         SA_SharePens, TRUE,
  29.                                                          TAG_DONE))
  30.         return TRUE;
  31.     else
  32.         printf("Error: could not create screen\n");
  33.     return FALSE;
  34. }
  35.  
  36. void closeScreen()
  37. {
  38.     if(screen)
  39.     {
  40.         CloseScreen(screen);
  41.         /* Set to NULL to indicate that it's been closed */
  42.         screen = NULL;
  43.     }
  44. }
  45.  
  46. struct Screen* getScreen()
  47. {
  48.     return screen;
  49. }
  50.